<?php echo js('admin/settings.js');?>
<?php echo css('admin/fcbkcomplete/fcbkcomplete.css');?>
<?php echo js('jquery/fcbkcomplete/jquery.fcbkcomplete.min.js');?>
<script type="text/javascript">
jQuery(function($){
	$("#attraction_id").fcbkcomplete({
        json_url: '<?php echo site_url('admin/catalog/json_attraction')?>',
        addontab: true,                   
        maxitems: 10,
        input_min_size: 0,
        height: 10,
        cache: true,
        newel: true,
        select_all_text: "select"
	});
	$("#pickuppoint_id").fcbkcomplete({
        json_url: '<?php echo site_url('admin/catalog/json_pickuppoint')?>',
        addontab: true,                   
        maxitems: 10,
        input_min_size: 0,
        height: 10,
        cache: true,
        newel: true,
        select_all_text: "select"
	});
	$("#city_id").fcbkcomplete({
        json_url: '<?php echo site_url('admin/catalog/json_region')?>',
        addontab: true,                   
        maxitems: 10,
        input_min_size: 0,
        height: 10,
        cache: true,
        newel: true,
        select_all_text: "select"
	});
});
</script>
<?php echo js('jquery/popupWindow/jquery.popupWindow.js');?>
<script type="text/javascript">
	function delte_pickup_image(){
		$('#pickup_image_holder').html("");
		$('#pickup_image').val("");
	}
	jQuery(function($){
		$('#a_pickup').popupWindow({height:500, width:800, centerBrowser:1}); 
	});
</script>
<div id="page-heading"><h1><?php echo sprintf(lang('dailyplans.edit_title'), def_lang($dailyplan, 'name', CURRENT_LANGUAGE)); ?></h1></div>
<?php $this->load->view('partials/notices'); ?>
<form method="post" action="<?php echo site_url('admin/catalog/edit_dailyplan/'. $tour_id. '/'. $dailyplan->id);?>" >
<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
		<tr>
			<th valign="top"><?php echo lang('dailyplans.departure_city_id'); ?><span class="require">*</span>:</th>
			<?php 
			$cities_option = array();
			foreach($cities as $city){
				$cities_option[$city->id] = empty($city->name)? lang('global:empty'): $city->name;
			}
			?>
			<td><?php echo form_dropdown('departure_city_id', $cities_option, $dailyplan->departure_city_id, 'id="departure_city_id" class="select_box"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('dailyplans.destination_city_id'); ?><span class="require">*</span>:</th>
			<td><?php echo form_dropdown('destination_city_id', $cities_option, $dailyplan->destination_city_id, 'id="destination_city_id" class="select_box"'); ?></td>
		</tr>
		<tr>
			<?php 
			$cities_option = array();
			foreach($hotels as $hotel){
				$hotels_option[$hotel->id] = empty($hotel->name)? lang('global:empty'): $hotel->name;
			}
			?>
			<th valign="top"><?php echo lang('dailyplans.hotel_id'); ?><span class="require">*</span>:</th>
			<td><?php echo form_dropdown('hotel_id', array(0 => lang('global:select-pick')) + $hotels_option, $dailyplan->hotel_id, 'id="hotel_id" class="select_box"'); ?></td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('dailyplans.attraction_id'); ?><span class="require">*</span>:</th>
			<td>
			<select id="attraction_id" name="attraction_id">
                <?php 
				$attractions_option = array();
				foreach($attractions as $attraction){
					foreach($dailyplan->attraction_id as $att_id){
						if($att_id->id == $attraction->id){
							$attractions_option[$attraction->id] = empty($attraction->name)? lang('global:empty'): $attraction->name;
						}
					}
				}
				?>
				<?php foreach($attractions_option as $key => $option):?>
					<option value="<?php echo $key?>" class="selected"><?php echo $option;?></option>
				<?php endforeach;?>
            </select>
			</td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('dailyplans.city_id'); ?><span class="require">*</span>:</th>
			<td>
			<select id="city_id" name="city_id">
                <?php 
				$cities_option = array();
				foreach($cities as $city){
					foreach($dailyplan->city_id as $att_cityid){
						if($att_cityid->id == $city->id){
							$cities_option[$city->id] = empty($city->name)? lang('global:empty'): $city->name;
						}
					}
				}
				?>
				<?php foreach($cities_option as $key => $option):?>
					<option value="<?php echo $key?>" class="selected"><?php echo $option;?></option>
				<?php endforeach;?>
            </select>
			</td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('dailyplans.pickup_point_id'); ?><span class="require">*</span>:</th>
			<td>
			<select id="pickuppoint_id" name="pickuppoint_id">
                <?php 
				$pickuppoints_option = array();
				foreach($pickuppoints as $pickuppoint){
					foreach($dailyplan->pickuppoint_id as $att_pickuppointid){
						if($att_pickuppointid->id == $pickuppoint->id){
							$pickuppoints_option[$pickuppoint->id] = empty($pickuppoint->name)? lang('global:empty'): $pickuppoint->name;
						}
					}
				}
				?>
				<?php foreach($pickuppoints_option as $key => $option):?>
					<option value="<?php echo $key?>" class="selected"><?php echo $option;?></option>
				<?php endforeach;?>
            </select>
			</td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('dailyplans.day'); ?><span class="require">*</span>:</th>
			<td>
			<?php echo form_dropdown('day', array(1 => 1,2 => 2,3 => 3,4 => 4,5 => 5,6 => 6,7 => 7,8 => 8,9 => 9,10 => 10), $dailyplan->day, 'id="day" class="select_box"'); ?>
			</td>
		</tr>
		<tr>
			<th valign="top"><?php echo lang('dailyplans.image'); ?>:</th>
			<td>
			<input type="hidden" value="<?php echo $dailyplan->image?>" name="image" id="pickup_image"/>
			<a href="<?php echo site_url('admin/folders/pickup_image')?>" id="a_pickup"><img src="<?php echo image_url('admin/shared/icon.png')?>"/></a>
			<div id="pickup_image_holder">
			<?php if(!empty($dailyplan->image)):?>
				<a href="javascript:void(0);" onclick="delte_pickup_image()"><img src="<?php echo site_url('files/thumb/' . $dailyplan->image . '/64/64?'. rand(0, 99)); ?>" title="click to delete"/></a>
			<?php endif;?>
			</div>
			</td>
		</tr>
</table>	
<table border="0" cellpadding="0" cellspacing="0"  id="id-form" style="width:100%;">
		<tr>
			<th colspan="3">
			<div id="usual-tab" class="usual-tab">
				<ul class="idTabs"> 
					<?php foreach($supported_languages as $lang => $content): ?>
						<li><a href="#<?php echo $lang;?>"><span style="font-weight: bold; font-size:12px;"><?php echo $content['name'];?></span></a></li>
					<?php endforeach; ?>
				</ul>
				<?php foreach($supported_languages as $lang => $content): ?>
					<div id="<?php echo $lang;?>" class="lang_content">
						<fieldset>
							<table border="0" cellpadding="0" cellspacing="0"  id="id-form" style="width:100%;">
							<tr>
								<th valign="top"><?php echo lang('dailyplans.name_label'); ?><span class="require">*</span>:</th>
								<td><?php echo form_input('name_'. $lang, def_lang($dailyplan, 'name', $lang), 'class="inp-form"'); ?></td>
							</tr>
							<tr>
								<th valign="top"><?php echo lang('dailyplans.detail'); ?><span class="require">*</span>:</th>
								<td><?php echo form_textarea('detail_'. $lang, def_lang($dailyplan, 'detail', $lang), 'class="form-textarea"'); ?>
								<?php echo display_ckeditor(ck_config_simple('detail_'. $lang)); ?>
								</td>
							</tr>
							<tr>
								<th valign="top"><?php echo lang('dailyplans.tips'); ?><span class="require">*</span>:</th>
								<td><?php echo form_textarea('tips_'. $lang, def_lang($dailyplan, 'tips', $lang), 'class="form-textarea"'); ?>
								<?php echo display_ckeditor(ck_config_simple('tips_'. $lang)); ?>
								</td>
							</tr>
							</table>
						</fieldset>	
					</div> 
				<?php endforeach; ?> 
			</div> 
			</th>
		</tr>
	<tr>
		<th>&nbsp;</th>
		<td valign="top">
			<input type="submit" value="" class="form-submit" />
			<input type="reset" value="" class="form-reset"  />
		</td>
		<td></td>
	</tr>
	</table>
	<input type="hidden" name="tour_id" value="<?php echo $tour_id?>"/>	
	<input type="hidden" name="id" value="<?php echo $dailyplan->id?>"/>	
</form>	
